﻿ <%if(!IsUserLogin())%>
<!--登录-->
<div class="maskBg"  id="login"  style=" display:none;">
 <form id="loginform" name="loginform" url="{config.webpath}tools/submit_ajax.ashx?action=user_login">
  
  <div class="loginWarp" style="margin-top:-160px;">
    
  <div class="close"><a href="javascript:hide('login')"><span></span></a></div>
    
    <div class="form-group">
      <input type="text" id="txtUserName" placeholder="手机号码/用户名" class="form-control">
    </div>
    <div class="form-group">
      <input type="password" placeholder="请输入密码" id="txtPassword" class="form-control">
    </div>
    <div class="form-group">
      <input class="btn btn-primary short100 btn-big" id="btnSubmit" name="btnSubmit" type="submit" value="登录">
    </div>
   
    <div class="form-group">
      <div class="tet">您可以以访客身份继续浏览或者完成订购。</div>
      <input class="btn btn-info short100 btn-big" onclick="GuestSet();" type="button" value="以访客身份继续">
    </div>
    
    <div class="form-group" style="overflow:hidden;">
      <div class="left short45 center">
        <input class="btn btn-info-outline short100" onclick="openreg()" type="button" value="注册">
      </div>
    <div class="right short45 center">
        <input class="btn btn-info-outline short100" onclick="openrpwd();" type="button" value="找回密码">
      </div>
    </div>
    
  </div>
  </form>

      <script type="text/javascript">
//          var api = frameElement.api, W = api.opener;

          $(function () {
              //提交表单
              $("#btnSubmit").bind("click", function () {
                  if ($("#txtUserName").val() == "" || $("#txtPassword").val() == "") {
                      $.dialog.tips("请填写用户名和登录密码！", 2, "32X32/hits.png");

                      return false;
                  }
                  var htmlbut = $("#btnSubmit").val();
                  $.ajax({
                      type: "POST",
                      url: $("#loginform").attr("url"),
                      dataType: "json",
                      data: {
                          "txtUserName": $("#txtUserName").val(),
                          "txtPassword": $("#txtPassword").val(),
                          "chkRemember": true
                      },
                      timeout: 20000,
                      beforeSend: function (XMLHttpRequest) {
                          $("#btnSubmit").attr("disabled", true);

                          $("#btnSubmit").val("正在登录，请稍候...");
                      },
                      success: function (data, textStatus) {
                          if (data.status == 1) {
                              if (typeof (data.url) == "undefined") {

                                  hide('login');


                              } else {

                                  hide('login');

                              }
                              if (data.number > 0) {
                                  location.reload();
                              }
                              else {
                                  logincke();
                                  GetAddress();
                              }
                          } else {
                              $("#btnSubmit").attr("disabled", false);
                              $("#btnSubmit").val(htmlbut);

                              $.dialog.tips(data.msg, 4, "32X32/hits.png");
                          }
                      },
                      error: function (XMLHttpRequest, textStatus, errorThrown) {
                          $.dialog.tips(data.msg, 4, "32X32/hits.png");
                          $("#btnSubmit").attr("disabled", false);
                      }
                  });
                  return false;
              });
          });
          </script>
    <script type="text/javascript">
        function GuestSet() {
            $.ajax({
                type: "POST",
                url: "{config.webpath}tools/submit_ajax.ashx?action=GuestSet",
                dataType: "json",
                timeout: 20000,
                success: function (data, textStatus) {
                    //location.reload(true);
                    //api.close();
                    logincke();
                    hide("login");
                }
            });
        }
    </script>
 </div>
 
 <script type="text/javascript">
     function show(obj) {
         $("#" + obj).show();
     }
     function hide(obj) {
         $("#" + obj).hide();
     }
     function openreg() {
         $("#login").hide();
         $("#reg").show();
     }
      function openrep() {
         $("#rep").hide();
         $("#login").show();
     }
     function openrpwd()
     {
     
     $("#login").hide();
         $("#rep").show();

     }
     $(function () {
     <%if(showlogin)%>
      $("#login").show();
     <%/if%>
     });
 </script>


 <!--注册-->
   <div class="maskBg" id="reg"  style=" display:none;">
     
      
  <div class="loginWarp">
    
    <div class="close"><a href="javascript:hide('reg');"><span></span></a></div>
  
    <div class="form-group">
      <input type="text" placeholder="请输入手机号码"  id="txtMobile" name="txtMobile" class="form-control">
     
    </div>
    <div class="form-group">
      <input type="text" placeholder="请填写验证码"  id="txtCode" name="txtCode"  class="form-control short50 left mar_r10">
      <input class="btn btn-info short45"  id="btnSendcode" type="button" url="{config.webpath}tools/submit_ajax.ashx?action=user_register_smscode" value="获取验证码">
    </div>
    <div class="form-group">
      <input type="password" placeholder="请输入密码" id="rtxtPassword" name="txtPassword" class="form-control">
    </div>
    <div class="form-group">
      <input type="password" placeholder="再次确认密码" id="txtPassword1" name="txtPassword1" class="form-control">
    </div>
    <div class="form-group">
      <input class="btn btn-primary short100 btn-big" id="rbtnSubmit" type="submit" value="确认">
    </div>
  </div>
  

  <script type="text/javascript">

      $(function () {
          //显示验证码
          $("#txtCode").bind("focus", function () {
              $("#verifyCode").show();
          });

          //发送短信
          $("#btnSendcode").click(function () {
              //检查是否输入手机号码
              if ($("#txtMobile").val() == "") {
                  $.dialog.tips("对不起，请先输入手机号码！", 2);
                  return false;
              }
              //设置按钮状态
              $("#txtCode").prop("disabled", false);
              $("#btnSendcode").prop("disabled", true);
              $.ajax({
                  type: "POST",
                  url: $("#btnSendcode").attr("url"),
                  dataType: "json",
                  data: {
                      "mobile": $("#txtMobile").val()
                  },
                  timeout: 20000,
                  success: function (data, textStatus) {
                      if (data.status == 1) {
                          $.dialog.tips(data.msg, 2, "32X32/succ.png", function () { });
                      } else {
                          $("#btnSendcode").prop("disabled", false);
                          $.dialog.tips(data.msg, 2);
                      }
                    
                  },
                  error: function (XMLHttpRequest, textStatus, errorThrown) {
                      $("#btnSendcode").prop("disabled", false);
                      $.dialog.tips("状态：" + textStatus + "；出错提示：" + errorThrown, 2);
                  }
              });
          });

          $("#mbtnSendcode").click(function () {
              //检查是否输入手机号码
              if ($("#mtxtMobile").val() == "") {
                  $.dialog.tips("对不起，请先输入手机号码！", 2);
                  return false;
              }
              //设置按钮状态
              $("#mtxtCode").prop("disabled", false);
              $("#mbtnSendcode").prop("disabled", true);
              $.ajax({
                  type: "POST",
                  url: $("#mbtnSendcode").attr("url"),
                  dataType: "json",
                  data: {
                      "mobile": $("#mtxtMobile").val()
                  },
                  timeout: 20000,
                  success: function (data, textStatus) {
                      if (data.status == 1) {
                          $.dialog.tips(data.msg, 2, "32X32/succ.png", function () { });
                      } else {
                          $("#mbtnSendcode").prop("disabled", false);
                          $.dialog.tips(data.msg, 2);
                      }
                    
                  },
                  error: function (XMLHttpRequest, textStatus, errorThrown) {
                      $("#mbtnSendcode").prop("disabled", false);
                      $.dialog.tips("状态：" + textStatus + "；出错提示：" + errorThrown, 2);
                  }
              });
          });
          $("#rbtnSubmit").bind("click", function () {
              if ($("#txtMobile").val() == "") {
                  $.dialog.tips("对不起，请先输入手机号码！", 2, "32X32/hits.png");
                  return false;
              }
              if ($("#txtCode").val() == "") {
                  $.dialog.tips("对不起，请输入验证码！", 2, "32X32/hits.png");
                  return false;
              }
              if ($("#rtxtPassword").val() == "") {
                  $.dialog.tips("对不起，请输入密码！", 2, "32X32/hits.png");
                  return false;
              }
              var pwd = $("#rtxtPassword").val();


              if (pwd.length < 6 || pwd.length > 12) {
                  $.dialog.tips("密码范围在6-20位之间！", 2, "32X32/hits.png");
                  return false;
              }
              if (pwd != $("#txtPassword1").val()) {
                  $.dialog.tips("两次输入的密码不一致！", 2, "32X32/hits.png");
                  return false;
              }

              $.ajax({


                  data: {
                      "txtMobile": $("#txtMobile").val(),
                      "txtCode": $("#txtCode").val(),
                      "txtPassword": $("#rtxtPassword").val()
                  },
                  timeout: 20000,
                  beforeSend: showRequest,
                  success: showResponse,
                  error: showError,
                  url: "{config.webpath}tools/submit_ajax.ashx?action=newuser_register",
                  type: "post",
                  dataType: "json",
                  timeout: 60000
              });
          });
          //初始化验证表单


          //表单提交前
          function showRequest(formData, jqForm, options) {
              $("#rbtnSubmit").val("正在提交...")
              $("#rbtnSubmit").prop("disabled", true);
              // $("#chkAgree").prop("disabled", true);
          }
          //表单提交后
          function showResponse(data, textStatus) {
              if (data.status == 1) { //成功
              
                  hide('reg');
              } else { //失败
                  $.dialog.tips(data.msg, 2);
                  $("#rbtnSubmit").val("再次提交");
                  $("#rbtnSubmit").prop("disabled", false);
                  // $("#chkAgree").prop("disabled", false);
                  return false;
              }
          }
          //表单提交出错
          function showError(XMLHttpRequest, textStatus, errorThrown) {
              $.dialog.tips("状态：" + textStatus + "；出错提示：" + errorThrown, 2);
              $("#rbtnSubmit").val("再次提交");
              $("#rbtnSubmit").prop("disabled", false);
              return false;
              //$("#chkAgree").prop("disabled", false);
          }
      });
  </script>
  </div>
      <script type="text/javascript">
          $(function () {
              //初始化表单
              AjaxInitForm('pwd_form', 'mbtnSubmit', 0, 'turl');
          });
    </script>
  <!--找回密码-->
   <form id="pwd_form" name="pwd_form" url="{config.webpath}tools/submit_ajax.ashx?action=muser_repassword">
  <div class="maskBg" id="rep"  style=" display:none;">
     
      
  <div class="loginWarp">
    
    <div class="close"><a href="javascript:hide('rep');"><span></span></a></div>
  
    <div class="form-group">
      <input type="text" placeholder="请输入手机号码"   datatype="m" nullmsg="请再输入手机号码" sucmsg=" " id="mtxtMobile" name="mtxtMobile" class="form-control">
     
    </div>
    <div class="form-group">
      <input type="text" placeholder="请填写验证码"  datatype="s4-20"   id="mtxtCode" name="mtxtCode"  class="form-control short50 left mar_r10">
      <input class="btn btn-info short45"   type="button" url="{config.webpath}tools/submit_ajax.ashx?action=user_register_smscode" id="mbtnSendcode" value="获取验证码">
    </div>
    <div class="form-group">
      <input type="password" placeholder="请输入密码" datatype="*6-20" nullmsg="请输入密码" errormsg="密码范围在6-20位之间" id="mtxtPassword" name="mtxtPassword" class="form-control">
    </div>
    <div class="form-group">
      <input type="password" placeholder="再次确认密码"  datatype="*" recheck="mtxtPassword" nullmsg="请再输入一次密码" errormsg="两次输入的密码不一致"
                            sucmsg=" " id="mtxtPassword1" name="mtxtPassword1" class="form-control">
    </div>
    <div class="form-group">
      <input class="btn btn-primary short100 btn-big" id="mbtnSubmit" type="submit" value="确认" />
    </div>
  </div>
  

  
  </div>
 </form>
  <%/if%>